package org.e_gold.schedule;

import org.apache.log4j.Logger;
import org.e_gold.factory.ConfigCrawler;
import org.e_gold.factory.Manager;
import org.e_gold.factory.crawler.Bet365CrawlerThread;
import org.e_gold.factory.export.MonitorThread;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MainJob implements InitializingBean {

	private static final Logger	logger	= Logger.getLogger(MainJob.class);

	@Autowired
	private Manager				manager;

	@Autowired
	private MonitorThread		monitor;

	@Autowired
	private Bet365CrawlerThread	bet365CrawlerThread;

	@Autowired
	private ConfigCrawler		configCrawler;

	@Override
	public void afterPropertiesSet() throws Exception {

		logger.info("Main Thread manager");
		manager.setName("GoldDiger-Main");
		manager.start();

		logger.info("Monitor Thread initial and start");
		monitor.setName("GoldDiger-Monitor-Bet-Exporter");
		monitor.start();

		bet365CrawlerThread.setName("GoldDiger-Crawler-Bet365");
		bet365CrawlerThread.initAndStart();

		configCrawler.setName("GoldDiger-Monitor-Get-Config");
		configCrawler.start();
	}
}
